package PubSub;

import java.util.ArrayList;
import java.util.List;

/**
 * @author duanzhizhou
 * @date 2024/10/10
 */
public abstract class AbstractSubject{
    List<Observer> list = new ArrayList<>();
    
    String name;
    String status;
    
    protected void attach(Observer observer) {
        list.add(observer);
    }
    
    protected void detach(Observer observer) {
        list.remove(observer);
    }
    
    protected void notifyObservers() {
        for (Observer o : list) {
            o.update(this);
        }
    }
}
